# Maintainer: Bruno Pagani <archange@archlinux.org>
# Maintainer: Daniel Bermond <dbermond@archlinux.org>

pkgname=vc-intrinsics
pkgver=0.11.0
pkgrel=2
pkgdesc="Set of new intrinsics on top of core LLVM IR instructions that represent SIMD semantics of a program targeting GPU"
arch=(loong64 x86_64)
url="https://github.com/intel/vc-intrinsics"
license=(MIT)
makedepends=(cmake python llvm git)
# From IGC release notes or latest release
_commit=dd72efa3b4aafdbbf599e6f3c6f8c55450e348de
source=(git+${url}.git#commit=$_commit)
sha256sums=(SKIP)

pkgver() {
  cd ${pkgname}
  git describe --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./;s/-/+/'
}

prepare() {
  cd ${pkgname}
  git revert -n bda6db9b23d695998faac74ace4094adb285ca28
}

build() {
  export CXXFLAGS+=" -ffat-lto-objects"
  cmake -B build -S ${pkgname} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DLLVM_DIR=/usr/lib/cmake/llvm \
    -Wno-dev
  make -C build
}

package() {
  make -C build DESTDIR="${pkgdir}" install
}
